<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>添加水司</title>
    <link rel="stylesheet" th:href="@{/component/pear/css/pear.css}" />
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <div class="layui-form-item">
                    <label class="layui-form-label">水司名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="customerName" lay-verify="title" autocomplete="off"    placeholder="请输入水司名称" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">水司联系人</label>
                    <div class="layui-input-block">
                        <input type="text"  name="customerContact" lay-verify="title" autocomplete="off"    placeholder="请输入水司联系人" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">联系人电话</label>
                    <div class="layui-input-block">
                        <input type="text"  name="customerTelephone"  lay-verify="title" autocomplete="off"    placeholder="请输入联系人电话" class="layui-input">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="customer-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script th:src="@{/component/layui/layui.js}"></script>
<script th:src="@{/component/pear/pear.js}"></script>
<script>
layui.use(['form','jquery'],function(){
    let form = layui.form;
    let $ = layui.jquery;

    form.on('submit(customer-save)', function(data){
        $.ajax({
            url:'/api/customer/save',
            data:JSON.stringify(data.field),
            dataType:'json',
            contentType:'application/json',
            type:'post',
            success:function(result){
                if(result.code=="1000"){
                    layer.msg(result.message,{icon:1,time:1000},function(){
                        parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                        parent.layui.table.reload("customer-table");
                    });
                }else{
                    layer.msg(result.message,{icon:2,time:1000});
                }
            }
        })
        return false;
    });
})
</script>
<script>
</script>
</body>
</html>